package com.example.demo.customer;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.stereotype.Component;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;

@Entity
@Table
public class Customer {

       @Id
        private  long id;

        @NotBlank(message = "name 不可以为空")
        private  String name;

        @NotBlank
        @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
        private  String password;

        @NotBlank(message = "email 不可以为空")
        @Email
        private String email;

    public Customer() {

    }

    @JsonProperty("customerId")
        public long getId() {
            return id;
        }

        public long getcustomerId(){
            return id;
        }

        public String getName() {
            return name;
        }

        public String getEmail() {
            return email;
        }
        @JsonIgnore
        public String getPassword(){
            return password;
        }



        public Customer(long id, String name, String password, String email) {
            this.id = id;
            this.name = name;
            this.password = password;
            this.email = email;
        }

    @Override
    public String toString() {
        return "Customer{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                '}';
    }



}
